package org.example.myproject0021.projec.project.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.example.myproject0021.projec.project.pojo.library;

import java.util.List;

@RestController
@CrossOrigin(origins = "*")
public class libraryController {
    @Autowired
    org.example.myproject0021.projec.project.mapper.libraryMapper libraryMapper;

    @GetMapping("/list")
    public List<library> list() {
        return libraryMapper.selectList(null);
    }

    @GetMapping("/get")
    public library get(Integer id) {
        return libraryMapper.selectById(id);
    }
    @PostMapping("/add")
    public void add(@RequestBody library library) {
        libraryMapper.insert(library);
    }

    @PostMapping("/update")
    public void update(@RequestBody library library) {
        libraryMapper.updateById(library);
    }
    @DeleteMapping("/delete")
    public void delete(Integer id) {
        libraryMapper.deleteById(id);
    }
}
